//---------------------------------------------------------------------------
#ifndef SenhasH
#define SenhasH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "Cadpad.h"
#include "PHDS.h"
#include <Buttons.hpp>
#include <ExtCtrls.hpp>
#include <Menus.hpp>
#include "PHEdit.h"
#include "PHLabel.h"
#include "stdm.h"
#include "CADPAD.h"
#include "CGAUGES.h"
#include "PHCombo.h"
#include "PHCheck.h"
//---------------------------------------------------------------------------
class TCPSenhas : public TCadPad1
{
__published:	// IDE-managed Components
        PHLabel *PHLabel1;
        PHEdit *PHEdit1;
        PHLabel *PHLabel2;
        PHEdit *PHEdit2;
        PHLabel *PHLabel3;
        PHEdit *PHEdit3;
        TBitBtn *BitBtn2;
        TBitBtn *BitBtn3;
        TBitBtn *BitBtn4;
        PHLabel *PHLabel4;
        PHEdit *PHEdit4;
	PHLabel *PHLabel5;
	PHComboBox *PHComboBox1;
	PHLabel *PHLabel6;
	PHEdit *PHEdit5;
 TGroupBox *GroupBox1;
 PHCheckBox *PHCheckBox5;
 PHCheckBox *PHCheckBox2;
 PHCheckBox *PHCheckBox4;
 PHCheckBox *PHCheckBox3;
 PHCheckBox *PHCheckBox1;
        void __fastcall FormDestroy(TObject *Sender);
        void __fastcall BitBtn2Click(TObject *Sender);
        void __fastcall BitBtn3Click(TObject *Sender);
        void __fastcall BitBtn4Click(TObject *Sender);
        void __fastcall PHDS1AfterOpen(TObject *Sender);
        void __fastcall PHDS1AfterPost(TObject *Sender);
        void __fastcall FormShow(TObject *Sender);
        void __fastcall PHDS1AfterDelete(TObject *Sender);
        void __fastcall PHDS1AfterRead(TObject *Sender);
        void __fastcall PHDS1AfterEdit(TObject *Sender);
        void __fastcall SpeedButton12Click(TObject *Sender);
        void __fastcall PHDS1Post(TObject *Sender);
        void __fastcall PHDS1AfterInsert(TObject *Sender);
        void __fastcall PHDS1BeforeInsert(TObject *Sender);
        void __fastcall FormCreate(TObject *Sender);
        void __fastcall PHDS1BeforeDelete(TObject *Sender);
	void __fastcall PHDS1BeforePost(TObject *Sender);
	void __fastcall PHComboBox1Change(TObject *Sender);
	void __fastcall PHDS1Delete(TObject *Sender);
	void __fastcall PHDS1BeforeEdit(TObject *Sender);
private:	// User declarations
        void __fastcall GravaSeguranca(void);
        void __fastcall GetGTSenha(int Elemento,AnsiString &Resultado,PHDataSource *DS);
        void __fastcall GetGTNome(int Elemento,AnsiString &Resultado,PHDataSource *DS);
        bool MenusPadrao;
        bool TabelasPadrao;
        int CodAntesDelete;
        AnsiString NomeOld;
public:		// User declarations
        __fastcall TCPSenhas(TComponent* Owner);
        struct SENHAS *SEN;
};
class MENPER:public TObject
{
 public:
   char Ativo;
   AnsiString Titulo;
};
class TABPER:public TObject
{
 public:
   char Incluir;
   char Alterar;
   char Eliminar;
   AnsiString Titulo;
};
//---------------------------------------------------------------------------
extern PACKAGE TCPSenhas *CPSenhas;
//---------------------------------------------------------------------------
class SENHASUTIL
{
private:
    void MontaBits(UCHAR Byte);
    UCHAR MontaByte(TBits *Bt,int Pos,char Quantos);
    int NivelMenu;
    void __fastcall CarregaMenus(TMenuItem *Menu);
    void __fastcall CarregaTabelas(void);
    struct BYTE
     {
      UCHAR Bit8:1;
      UCHAR Bit7:1;
      UCHAR Bit6:1;
      UCHAR Bit5:1;
      UCHAR Bit4:1;
      UCHAR Bit3:1;
      UCHAR Bit2:1;
      UCHAR Bit1:1;
     } B;
public:
    void VerificaIntegridadeArquivosSenha(PHDataSource *DSSenhas);
    void ConverteParaNovoFormato(struct SENHAS *Sn);
    void ConverteAfterRead(struct SENHAS *Sn);
    void ConverteAfterRead(struct SENHAS *Sn,char Qual);
    void __fastcall CarregaGeral(void);
    TStringList *MenusPermitidos;
    TStringList *TabelasPermissao;
};
extern class SENHASUTIL SenUtil;
//---------------------------------------------------------------------------
#endif
